//Ϸ  Development޸ 2018-12-31
procedure TDxHint.DirectPaint(dsurface: TDXTexture);
var
  fy, nY, L, T, i, oSize: Integer;
  OldColor, BrushColor, FontColor: TColor;
  FontStyle: TFontStyles;
  HintSurface_B: TDirectDrawSurface;
begin
  if Assigned(FOnDirectPaint) then
  begin
    FOnDirectPaint(self, dsurface);
    Exit;
  end;

  L := SurfaceX(Left);
  T := SurfaceY(Top);
  HintSurface_B := TDirectDrawSurface.Create(g_DXCanvas);
  HintSurface_B.Size := Point(SCREENWIDTH - 100, SCREENHEIGHT - 5);
  HintSurface_B.Format := {D3DFMT_A4R4G4B4}D3DFMT_R5G6B5;
  HintSurface_B.Active := True;

  if tag = 0 then
  begin
    try
      OldColor := MainForm.Canvas.Font.Color;
      oSize := MainForm.Canvas.Font.Size;
      FontStyle := MainForm.Canvas.Font.Style;
      MainForm.Canvas.Font.Style := self.Font.Style;
      MainForm.Canvas.Font.Color := clBlack;
      MainForm.Canvas.Font.Size := self.Font.Size;
      MainForm.Canvas.Brush.Style := bsSolid;
      BrushColor := clWebDarkGray; //ܱɫ Development 2018-12-31
      g_DXCanvas.FillRectAlpha(Rect(L, T + 1, L + Width, T + Height - 1), BrushColor, 200);
      MainForm.Canvas.Brush.Style := bsClear;
      if (FSelected > -1) and (FSelected < FItems.count) then
      begin
        if (FItems.Objects[FSelected] = nil) then
        begin

          nY := T + (-MainForm.Canvas.Font.Height + LineSpace2) * FSelected;
          fy := nY + (-MainForm.Canvas.Font.Height + LineSpace2);
          if (nY < T + Height - 1) and (fy > T + 1) then
          begin
            if (fy > T + Height - 1) then
              fy := T + Height - 1;
            if (nY < T + 1) then
              nY := T + 1;
            g_DXCanvas.FillRectAlpha(Rect(L + 2, nY + 2, L + Width - 2, fy + 5), clBlue, 255);
          end;
        end;
      end;

      MainForm.Canvas.Brush.Style := bsClear;
      for i := 0 to FItems.count - 1 do
      begin
        if (FSelected = i) and (FItems.Objects[i] = nil) then
        begin
          FontColor := clWhite
        end
        else if (FItems.Objects[i] <> nil) then
          FontColor := clSilver
        else
        begin
          FontColor := clBlack;
        end;
        g_DXCanvas.TextOut(L + LineSpace2, LineSpace2 + T + (-MainForm.Canvas.Font.Height + LineSpace2) * i, FontColor, FItems.Strings[i]);
      end;
      MainForm.Canvas.Font.Style := FontStyle;
      MainForm.Canvas.Font.Color := OldColor;
      MainForm.Canvas.Font.Size := oSize;
    finally

    end;
    Exit;
  end;

  try
    OldColor := MainForm.Canvas.Font.Color;
    oSize := MainForm.Canvas.Font.Size;
    FontStyle := MainForm.Canvas.Font.Style;
    MainForm.Canvas.Font.Style := self.Font.Style;
    MainForm.Canvas.Font.Color := clWhite;
    MainForm.Canvas.Font.Size := self.Font.Size;
    BrushColor := clWebDarkGray; //ܱɫ Development 2018-12-31
    g_DXCanvas.FillRect(Rect(L, T + 1, L + Width, T + Height - 1),SetA(BrushColor,200));

    BrushColor := clHighlight; //ָѡʱıɫ Development 2018-12-31
    if (FSelected > -1) and (FSelected < FItems.count) then begin
      if (FItems.Objects[FSelected] = nil) then begin

        nY := T + (-MainForm.Canvas.Font.Height + LineSpace2) * FSelected;
        fy := nY + (-MainForm.Canvas.Font.Height + LineSpace2);
        if (nY < T + Height - 1) and (fy > T + 1) then begin
          if (fy > T + Height - 1) then fy := T + Height - 1;
          if (nY < T + 1) then nY := T + 1;
          g_DXCanvas.FillRectAlpha(Rect(L, nY + 2, L + Width, fy + 5),BrushColor,255);
        end;
      end;
    end;

    MainForm.Canvas.Brush.Style := bsClear;
    for i := 0 to FItems.count - 1 do begin
      if (FSelected = i) and (FItems.Objects[i] = nil) then begin
        FontColor := clWhite
      end else if (FItems.Objects[i] <> nil) then
        FontColor := clSilver
      else begin
        FontColor := clWhite;
      end;
      g_DXCanvas.TextOut(L + LineSpace2, LineSpace2 + T + (-MainForm.Canvas.Font.Height + LineSpace2) *      i,FontColor, FItems.Strings[i]);
    end;
    MainForm.Canvas.Font.Style := FontStyle;
    MainForm.Canvas.Font.Color := OldColor;
    MainForm.Canvas.Font.Size := oSize;
  finally

  end;
end;